package com.aura.springbook.common.util;

import com.aura.springbook.common.enums.BorrowStatusEnum;
import com.aura.springbook.model.BorrowRecord;

/**
 * 借阅相关工具类
 */
public class BorrowUtil {
    
    /**
     * 检查借阅记录是否已归还
     * @param borrowRecord 借阅记录
     * @return 是否已归还
     */
    public static boolean isReturned(BorrowRecord borrowRecord) {
        return borrowRecord != null && borrowRecord.getStatusEnum() == BorrowStatusEnum.RETURNED;
    }
    
    /**
     * 检查借阅记录是否未归还
     * @param borrowRecord 借阅记录
     * @return 是否未归还
     */
    public static boolean isNotReturned(BorrowRecord borrowRecord) {
        return borrowRecord != null && borrowRecord.getStatusEnum() == BorrowStatusEnum.NOT_RETURNED;
    }
    
    /**
     * 获取借阅状态描述
     * @param borrowRecord 借阅记录
     * @return 状态描述
     */
    public static String getStatusDescription(BorrowRecord borrowRecord) {
        if (borrowRecord == null) {
            return "未知状态";
        }
        return borrowRecord.getStatusEnum().getDescription();
    }
}